var element = null;
var layer = null;
layui.use(['element', 'layer'], function () {
    element = layui.element; //Tab的切换功能，切换事件监听等，需要依赖element模块
    layer = layui.layer;

});

function addTab(url, title) {
    var layids = $(".layui-tab-title li[lay-id]");

    var content = "<iframe scrolling='auto' frameborder='0' src='" + url + "' style='width:100%; height:"+($(window).height()-175)+"px;'></iframe>";
    if (layids.length <= 0) {
        element.tabAdd('tabs', {
            title: title
            , content: content
            , id: title
        })
        element.tabChange('tabs', title);
    } else {
        var flag = false;
        $.each(layids, function () {
            if ($(this).attr("lay-id") == title) {
                flag = true;
                element.tabChange('tabs', title);
            }
        })
        if (!flag) {
            element.tabAdd('tabs', {
                title: title
                , content: content
                , id: title
            })
            element.tabChange('tabs', title);
        }
    }
}

function refreshSystem() {
    $.post("/admin/refreshSystem", {}, function (result) {
        if (result.success) {
            layer.msg("已成功刷新系统缓存", {
                icon: 6,
                offset: '150px',
            });
        } else {
            layer.msg("刷新系统缓存失败", {
                icon: 5,
                offset: '150px',
            });
        }
    }, "json");
}

